package com.example.demo.controller;


import com.example.demo.model.Borr;
import com.example.demo.service.BorrService;
import com.example.demo.tool.ResponseMessage;
import com.example.demo.tool.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 编写者：施皓
 * 编写时间：2019.5.28
 */
@RestController(value = "/Borr")
public class BorrController {
    @Autowired
    private BorrService borrService;

    @RequestMapping(value = "/getBorr")
    public String getStr(String str){
        return "你输入的名字叫" + str;

    }
    @CrossOrigin
    @RequestMapping(value = "/getBorrOne")
    public Borr getOne(Integer bid){
        return borrService.BorrKey(bid);
    }

    @CrossOrigin//解决跨越问题
    @RequestMapping(value = "getStatus")
    public List<Borr> getsex(){
        System.out.println("调用角色全部类型的接口");
        List<Borr> listBorr = borrService.getStatus();
        return listBorr;
    }

    @CrossOrigin
    @RequestMapping(value = "getAllBorr")
    public ResponseMessage getAllBorr(){
        List<Borr> listBorr = borrService.getAllBorr();
        System.out.println("调用角色全部信息的方法");
        Map<String,List> map = new HashMap<>();
        map.put("list",borrService.getAllBorr());
        return Result.success("200",map);
    }
    @CrossOrigin
    @RequestMapping(value = "/delBorr",method =  RequestMethod.GET)
    public int delData(Integer bid){
        return borrService.delBorr(bid);
    }

    @CrossOrigin
    @RequestMapping(value = "/insertBorr",method = RequestMethod.PUT)
    public int insertBorr(@RequestBody Borr borrmodel){
        //判断传入数据是否为空
        if (borrmodel!=null){

        }else {

        }
        return borrService.insertBorr(borrmodel);
    }
    @CrossOrigin
    @RequestMapping(value = "/updateBorr",method = RequestMethod.PUT)
    public  int updateData(@RequestBody Borr borrmodel){
        if (borrmodel!=null){

        }else {

            System.out.println("请输入数据");
        }
        return borrService.updateBorr(borrmodel);
    }
}
